From 3dc60ce1679c4c1788447690a11b98f33f64237f Mon Sep 17 00:00:00 2001 From: Ivan Baravy Date: Mon, 11 Mar 2019 21:34:41 +0000 Subject: [PATCH] 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 --- programs/system/scrsaver/Tupfile.lua | 4 ++ programs/system/scrsaver/scrsaver.asm | 86 +++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 programs/system/scrsaver/Tupfile.lua create mode 100644 programs/system/scrsaver/scrsaver.asm diff --git a/programs/system/scrsaver/Tupfile.lua b/programs/system/scrsaver/Tupfile.lua new file mode 100644 index 0000000000..cbb0afa6fd --- /dev/null +++ b/programs/system/scrsaver/Tupfile.lua @@ -0,0 +1,4 @@ +if tup.getconfig("NO_FASM") ~= "" then return end +HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../.." or tup.getconfig("HELPERDIR") +tup.include(HELPERDIR .. "/use_fasm.lua") +tup.rule("scrsaver.asm", FASM .. " %f %o " .. tup.getconfig("KPACK_CMD"), "scrsaver") diff --git a/programs/system/scrsaver/scrsaver.asm b/programs/system/scrsaver/scrsaver.asm new file mode 100644 index 0000000000..a0ec0a45fe --- /dev/null +++ b/programs/system/scrsaver/scrsaver.asm @@ -0,0 +1,86 @@ +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: