Setup: use .ini file for settings

git-svn-id: svn://kolibrios.org@5854 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
pathoswithin 2015-10-20 23:06:48 +00:00
parent cb95c307f3
commit d5954b2396

View File

@ -12,107 +12,132 @@ dd START
dd IM_END dd IM_END
dd I_END dd I_END
dd stack_area dd stack_area
dd boot_param dd param
dd 0 dd 0
include '../../../proc32.inc'
include '../../../macros.inc' include '../../../macros.inc'
include '../../../dll.inc'
;--------------------------------------------------------------- ;---------------------------------------------------------------
set_language_and_exit: BootSettings:
mcall 26,2,9 ; Set system language
cmp eax,1 mov word[param],0
je russian invoke ini.get_str, sz_ini, sz_system, sz_language, param, 2, 0
xor eax,eax mov ax, [param]
or ax, 0x2020 ; convert to lowercase
mov ecx,8
mov edi,langMarks
repnz scasw
jnz @f
neg ecx
add ecx,8
mcall 21,5
@@: @@:
mov [keyboard],eax
; Set keyboard layout
mov word[param],0
invoke ini.get_str, sz_ini, sz_system, sz_keyboard, param, 2, 0
mov ax, [param]
or ax, 0x2020
mov ecx,8
mov edi,langMarks
repnz scasw
jnz @f
neg ecx
add ecx,7
mov [keyboard],ecx
call _keyboard call _keyboard
jmp close
russian:
mov eax,3
jmp @b
;---------------------------------------------------------------
set_syslanguage_and_exit:
mcall 26,5
cmp eax,6
jne @f
xor eax,eax
@@: @@:
inc eax
mov [syslang],eax ; Set font smoothing
call _syslang mov dword[param],0
jmp close invoke ini.get_str, sz_ini, sz_system, sz_fontSmooth, param, 4, 0
;--------------------------------------------------------------- xor ecx,ecx
apply_all_and_exit: mov eax,[param]
mov byte[fileinfo],0 or eax,0x20202020
mcall 70,fileinfo cmp eax,'off '
call apply_all jz @f
jmp close inc ecx
;--------------------------------------------------------------- cmp eax,'on '
apply_all: jz @f
call fontApply cmp eax,'sbp '
call _syslang jnz .skipFont
call _lba_read inc ecx
call _pci_acc @@:
mcall 48,10
.skipFont:
; Enable/disable system speaker
mov dword[param],0
invoke ini.get_str, sz_ini, sz_system, sz_speaker, param, 4, 0
mov eax,[param]
or eax,0x20202020
cmp eax,'off '
jz @f
cmp eax,'on '
jnz .skipSpeaker
inc [speaker_mute]
@@:
call _speaker_mute call _speaker_mute
call _keyboard .skipSpeaker:
ret
;--------------------------------------------------------------- ; Set mouse speed
_syslang: invoke ini.get_int, sz_ini, sz_mouse, sz_speed, 1
mcall 21,5,[syslang] mov edx,eax
jmp loadtxt mcall 18,19,1
;---------------------------------------------------------------
_lba_read: ; Set mouse delay
mcall 21,11,[lba_read] invoke ini.get_int, sz_ini, sz_mouse, sz_delay, 1
ret mov edx,eax
;--------------------------------------------------------------- mcall 18,19,3
_pci_acc:
mcall 21,12,[pci_acc] ; Enable/disable LBA access for applications
ret mov dword[param],0
;--------------------------------------------------------------- invoke ini.get_str, sz_ini, sz_low_level, sz_lba, param, 4, 0
fontApply: xor ecx,ecx
mcall 48,10,[fontSmoothing] mov eax,[param]
ret or eax,0x20202020
;--------------------------------------------------------------- cmp eax,'off '
_speaker_mute: jz @f
mcall 18,8,1 cmp eax,'on '
cmp [speaker_mute],eax jnz .skipLBA
je @f
inc ecx inc ecx
mcall 18
@@: @@:
ret mcall 21,11
;--------------------------------------------------------------- .skipLBA:
_keyboard:
mov ebp,[keyboard] ; Enable/disable PCI access for applications
mov edx,[ebp*4+keymapTab] mov dword[param],0
mcall 21,2,1 invoke ini.get_str, sz_ini, sz_low_level, sz_pci, param, 4, 0
xor ecx,ecx
mov eax,[param]
or eax,0x20202020
cmp eax,'off '
jz @f
cmp eax,'on '
jnz close
inc ecx inc ecx
mov edx,[ebp*4+shiftKeymapTab] @@:
mcall 21 mcall 21,12
inc ecx jmp close
mov edx,[ebp*4+altKeymapTab]
mcall 21
mov edx,ebp
inc edx
mov cl, 9
mcall 21
ret
;--------------------------------------------------------------- ;---------------------------------------------------------------
START: START:
mov eax,boot_param mcall 68,11
cmp [eax],dword 'SLAN' stdcall dll.Load, @IMPORT
je set_syslanguage_and_exit push eax
test eax,eax
jnz close
cmp [eax],dword 'LANG' cmp [param],dword 'BOOT'
je set_language_and_exit jz BootSettings
pop eax
cmp [eax],dword 'BOOT'
je apply_all_and_exit
; get current settings ; get current settings
mcall 26,2,9 mcall 26,2,9
dec eax dec eax
mov [keyboard],eax mov [keyboard],eax
mcall 26,5 mcall 26,5
dec eax
mov [syslang],eax mov [syslang],eax
mcall 26,11 mcall 26,11
@ -132,7 +157,7 @@ START:
draw_infotext: draw_infotext:
mov eax,[syslang] mov eax,[syslang]
mov edi,[text] mov edi,[text]
lea esi,[eax*8+langs-8] lea esi,[eax*8+langs]
add edi,28 add edi,28
movsd movsd
movsd movsd
@ -244,21 +269,18 @@ button:
close: close:
pop eax pop eax
mcall -1 mcall -1
saveAll:
mov byte[fileinfo],2
mcall 70,fileinfo
ret
language1: language1:
dec [syslang] dec [syslang]
jnz @f jns @f
mov [syslang],6 mov [syslang],7
ret jmp @f
language2: language2:
inc [syslang] inc [syslang]
cmp [syslang],7 cmp [syslang],8
jnz @f jnz @f
mov [syslang],1 mov [syslang],0
ret @@:
jmp loadtxt
layout1: layout1:
dec [keyboard] dec [keyboard]
jns @f jns @f
@ -299,43 +321,135 @@ font2:
inc [fontSmoothing] inc [fontSmoothing]
@@: @@:
ret ret
apply_all:
call fontApply
call _syslang
call _lba_read
call _pci_acc
call _speaker_mute
call _keyboard
ret
_syslang:
mov ecx,[syslang]
inc ecx
mcall 21,5
ret
_lba_read:
mcall 21,11,[lba_read]
ret
_pci_acc:
mcall 21,12,[pci_acc]
ret
fontApply:
mcall 48,10,[fontSmoothing]
ret
_speaker_mute:
mcall 18,8,1
cmp [speaker_mute],eax
je @b
inc ecx
mcall 18
_keyboard:
mov ebp,[keyboard]
mov edx,[ebp*4+keymapTab]
mcall 21,2,1
inc ecx
mov edx,[ebp*4+shiftKeymapTab]
mcall 21
inc ecx
mov edx,[ebp*4+altKeymapTab]
mcall 21
mov edx,ebp
inc edx
mov cl, 9
mcall 21
ret
;--------------------------------------------------------------- ;---------------------------------------------------------------
loadtxt: loadtxt:
cmp [syslang],4 cmp [syslang],3
jne @f jz .ru
cmp [syslang],5
jz .et
mov [text],texteng
ret
.ru:
mov [text],textrus mov [text],textrus
ret ret
@@: .et:
cmp [syslang],6
jne @f
mov [text],textet mov [text],textet
ret ret
@@:
mov [text],texteng
ret
;--------------------------------------------------------------- ;---------------------------------------------------------------
onoff: onoff:
cmp [syslang],4 cmp [syslang],3
jne norus1 jz .ru
mov ebx,'„€ ' cmp [syslang],5
cmp eax,1 jz .et
je exitsub
mov ebx,'<27> '
ret
norus1:
cmp [syslang],6
jne noet1
mov ebx,'SEES'
cmp eax,1
je exitsub
mov ebx,'VÄL.'
ret
noet1:
mov ebx,'ON '
cmp eax,1
je exitsub
mov ebx,'OFF ' mov ebx,'OFF '
exitsub: test eax,eax
jz @f
mov ebx,'ON '
ret
.ru:
mov ebx,'<27> '
test eax,eax
jz @f
mov ebx,'„€ '
ret
.et:
mov ebx,'VÄL.'
test eax,eax
jz @f
mov ebx,'SEES'
@@:
ret
;---------------------------------------------------------------
saveAll:
; system language
mov eax,[syslang]
mov ax, [eax*2+langMarks]
mov [param],eax
invoke ini.set_str, sz_ini, sz_system, sz_language, param, 2
; keyboard layout
mov eax,[keyboard]
mov ax, [eax*2+langMarks]
mov [param],eax
invoke ini.set_str, sz_ini, sz_system, sz_keyboard, param, 2
; font smoothing
mov dword[param],'off'
cmp [fontSmoothing],0
jz @f
mov dword[param],'on '
cmp [fontSmoothing],1
jz @f
mov dword[param],'sbp'
@@:
invoke ini.set_str, sz_ini, sz_system, sz_fontSmooth, param, 3
; system speaker
mov dword[param],'off'
cmp [speaker_mute],0
jz @f
mov dword[param],'on '
@@:
invoke ini.set_str, sz_ini, sz_system, sz_speaker, param, 3
; LBA access for applications
mov dword[param],'off'
cmp [lba_read],0
jz @f
mov dword[param],'on '
@@:
invoke ini.set_str, sz_ini, sz_low_level, sz_lba, param, 3
; PCI access for applications
mov dword[param],'off'
cmp [pci_acc],0
jz @f
mov dword[param],'on '
@@:
invoke ini.set_str, sz_ini, sz_low_level, sz_pci, param, 3
ret ret
;--------------------------------------------------------------- ;---------------------------------------------------------------
align 4 align 4
@ -389,7 +503,6 @@ altKeymapTab:
dd be_keymap_alt_gr dd be_keymap_alt_gr
dd it_keymap_alt_gr dd it_keymap_alt_gr
setup.dat: ; file structure
syslang dd 0 syslang dd 0
keyboard dd 0 keyboard dd 0
lba_read dd 0 lba_read dd 0
@ -397,16 +510,30 @@ pci_acc dd 0
speaker_mute dd 0 speaker_mute dd 0
fontSmoothing dd 0 fontSmoothing dd 0
fileinfo: @IMPORT:
dd 0 library libini, 'libini.obj'
dd 0 import libini, \
dd 0 ini.get_str, 'ini_get_str',\
dd 4*6 ini.get_int, 'ini_get_int',\
dd setup.dat ini.set_str, 'ini_set_str',\
db '/SYS/SETTINGS/SETUP.DAT',0 ini.set_int, 'ini_set_int'
title db 'System settings',0 title db "System settings",0
hex db '0123456789ABCDEF' sz_ini db "/sys/settings/system.ini",0
sz_system db "system",0
sz_language db "language",0
sz_keyboard db "keyboard",0
sz_fontSmooth db "font smoothing",0
sz_speaker db "speaker mute",0
sz_mouse db "mouse",0
sz_speed db "speed",0
sz_delay db "delay",0
sz_low_level db "low-level",0
sz_lba db "LBA",0
sz_pci db "PCI",0
LLL = 56 LLL = 56
stringsAmount = 6 stringsAmount = 6
@ -415,6 +542,8 @@ align 4
text dd 0 text dd 0
langs: langs:
db 'ENGLISH FINNISH GERMAN RUSSIAN FRENCH ESTONIANBELGIAN ITALIAN ' db 'ENGLISH FINNISH GERMAN RUSSIAN FRENCH ESTONIANBELGIAN ITALIAN '
langMarks:
db 'enfiderufretesit'
textrus: textrus:
db 'Ÿ§ëª á¨á⥬ë : < > <20>ਬ¥­¨âì' db 'Ÿ§ëª á¨á⥬ë : < > <20>ਬ¥­¨âì'
@ -430,9 +559,9 @@ db '
texteng: texteng:
db 'System language : < > Apply ' db 'System language : < > Apply '
db 'Keyboard layout : < > Apply ' db 'Keyboard layout : < > Apply '
db 'LBA read enabled : - + Apply ' db 'Allow LBA access : - + Apply '
db 'PCI access for appl. : - + Apply ' db 'Allow PCI access : - + Apply '
db 'SPEAKER disabled : - + Apply ' db 'Disable SPEAKER : - + Apply '
db 'Font smoothing : - + Apply ' db 'Font smoothing : - + Apply '
db 'NOTE: Apply all ' db 'NOTE: Apply all '
@ -443,7 +572,7 @@ db 'S
db 'Klaviatuuri paigutus : < > Kinnita ' db 'Klaviatuuri paigutus : < > Kinnita '
db 'LBA lugemine lubatud : - + Kinnita ' db 'LBA lugemine lubatud : - + Kinnita '
db 'PCI juurdepääs programm. : - + Kinnita ' db 'PCI juurdepääs programm. : - + Kinnita '
db 'SPEAKER disabled : - + Kinnita ' db 'Disable SPEAKER : - + Kinnita '
db 'Font smoothing : - + Kinnita ' db 'Font smoothing : - + Kinnita '
db 'MÄRKUS: Kinnita kõik ' db 'MÄRKUS: Kinnita kõik '
@ -451,7 +580,7 @@ db 'SALVESTA SEADED ENNE KOLIBRIST V
include 'keymaps.inc' include 'keymaps.inc'
IM_END: IM_END:
boot_param: param:
rb 1024 rb 1024
stack_area: stack_area:
I_END: I_END: